<template>
  <div>
    <FilterTable
      ref="table"
      height="auto"
      :columns="columns"
      :dataSource="changeList"
      :isSelectColumn='false'
      :isColumnFilter='false'
      :isToperInfo='false'
      :isPagination='false'
      :onColumnsChange="columns => this.columns = columns"
    />
  </div>
</template>

<script>
import { queryChangeList } from '@/api/potenCus/customer/potenCusManage';
import { dictionary } from '@/utils/dictMixin';
import { formatDates } from '@/utils/validate';

export default {
  name: 'changeRecord',
  mixins: [dictionary],
  props: {
    rowData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    this.saveData = null;
    return {
      changeList: [],
      columns: this.createTableColumns(),
      recordId: ''
    };
  },
  created() {
    this.init();
  },
  activated () {
    this.init()
  },
  methods: {
    init() {
      console.log('变更历史有没有rowData',this.rowData)
      this.recordId = this.rowData.costomerBusinessId;
      if (this.recordId) {
        this.getAboutCluesList()
      } else {
        console.log('也没个商机id')
      }
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '发生时间',
          dataIndex: 'changeDate',
          filterType: 'input',
          render: props =>{
            return <span>{ formatDates(props.row.changeDate) } </span>
          }
        },
        {
          title: '操作人员',
          dataIndex: 'personnelName',
          filterType: 'input'
        },
        {
          title: '发生事项',
          dataIndex: 'changeMatter',
          filterType: 'checkbox',
          filterItems: this.createDictList('7045'),
          render: props => {
            return <span>{this.createDictText(props.row.changeMatter, '7045')}</span>;
          }
        },
        {
          title: '备注',
          dataIndex: 'remark',
          filterType: 'input'
        }
      ];
    },
    async getAboutCluesList() {
      const res = await queryChangeList(this.recordId)
      console.log('变更', res)
      if (res.resultCode === 200) {
        this.changeList = res.data;
      }
    },

  }
};
</script>

<style lang="less" scoped>
</style>

